<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/website/common/base.jsp"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${webname }-我的收藏</title>
<%@ include file="/website/common/common.jsp"%>
<link href="${webctx }/css/manage.css" rel="stylesheet" type="text/css" />
<link href="${webctx }/css/payment.css" rel="stylesheet" type="text/css" />
<style>
.buy-btn a{ width:80px; height:22px; border:1px solid #ff6767; color:#ff6767; display:block; font-size:12px; padding-left:2px; text-indent:18px;line-height:22px;}
.buy-btn i{ width:16px; height:16px; position:absolute; left:2px; top:4px; background:url(${webctx}/images/buyico.png) no-repeat;}
.buy-btn2 a{width:70px; height:22px;line-height:22px; color:#7F7F7F; display:block;text-align:center;font-size:14px;background:#eeeeee;margin-top:5px;}
.buy-btn a:hover{ color:#f00; border:1px solid #f00}
.buy-btn3{margin-top:5px;}
.buy-btn3 a{font-size:14px;}
.acc-btn{ width:120px; height:30px; line-height:30px;display:inline-block; font-size:15px; border-radius:2px; text-align:center;background:#fff; color:#23b0fc; border:1px solid #23b0fc}
.acc-btn:hover{background:#14ABFC;color:#fff}

.th-info{width:400px;}
.th-price{ width:150px;}
.th-amount{ width:150px;}
.td-pic{ width:105px;}
.td-price{ width:150px;}
.td-amount{ width:120px;}
.td-amount .buy-Num-bd{ margin-top:20px; width:50px; height:28px; line-height:28px; padding:0 18px;}
.td-amount .buy-Num-bd span{ width:24px; line-height:28px; height:28px;}
.td-amount .buy-Num-bd input{ width:30px; height:22px; line-height:22px;padding-left:8px}
.td-amount em{ padding:30px 0 0 45px; display:inline-block}
</style>
</head>

<body>
<%@ include file="/website/common/top.jsp"%>
<%@ include file="/website/common/head.jsp"%>
<%@ include file="/website/common/menu.jsp"%>

<div class="warp-body">
	<div class="inner clearfix">
    	<div class="left-main">
        	<div class="left-inner">
            	<%@ include file="/website/user/left.jsp"%>
            </div>
        </div>
    	<div class="right-main">
        	<div class="right-inner">
            	<div class="right-title"><span></span>我的商品收藏</div>
            	
                <!-- start -->
                <c:if test="${list.size()>0 }">
                <div style="text-align:right;background-color: #fff;padding:8px "><a class="acc-btn marginR8" href="javascript:dels();">批量删除</a></div>
            	<div class="cart-th">
	            	<ul class="clearfix">
	            		<li class="th th-chk">
	                    	<div class="cart-checkbox allbox">
	                            <input name="cartcheckbox" type="checkbox" value=""/>
	                            <label class="J_select">
	                            	<span class="chk-ico"></span> 全选
	                            </label>
	                        </div>
	                    </li>	
	            		<li class="th th-info"><div class="th-inner">商品信息</div></li>
	            		<li class="th th-price"><div class="th-inner">单价（元）</div></li>
	            		<li class="th th-amount"><div class="th-inner">数量</div></li>
	            		<li class="th th-op"><div class="th-inner">操作</div></li>
	            	</ul>
	            </div>
            	<div class="cart-bd">
            	<c:forEach items="${list }" var="product" varStatus="status">
	            	<div class="order-content" pid="${product.id }">
	                	<ul class="item-content clearfix">
	                		<li class="td td-chk">
	                			
	                        	<div class="cart-checkbox productbox">
	                            	<input name="cartcheckbox" type="checkbox" value="${product.id}"/>
	                            	<label class="J_select">                            		
	                            	</label>
	                            </div>
	                        </li>
	                        <li class="td td-pic">
	                        	<div class="td-inner"> 
	                            	<a href="${ctx }/product/info?priceid=${product.id}" target="_blank"><img src="<%=getRandomFileserver()%>${product.photo}" width="90" height="90" alt="" onerror="this.src='${webctx }/images/noimg.jpg'"></a>
	                            </div>
	                        </li>
	                		<li class="td td-info">
	                        	<div class="td-inner">
	                            	<div class="info-title">${product.productname } ${product.name }</div>
	                                <ul class="info-txt">
	                                	<li class="clearfix">
	                                    	<span class="tl">生产厂家： ${product.B_chanjia }</span>
	                                        <span>件装量： ${product.B_zhuanl }</span>
	                                    </li>
	                                    <li class="clearfix">
	                                    	<span class="tl">规　　格： ${product.B_guige }</span>
	                                        <span>单　位： ${product.unitname }</span>
	                                    </li>
	                                    <li class="clearfix">
	                                    	<span class="tl">批准文号：
	                                    		<c:choose>  
												    <c:when test="${fn:length(product.B_pzwh) > 12}">  
												        <c:out value="${fn:substring(product.B_pzwh, 0, 12)}..." />  
												    </c:when>  
												   <c:otherwise>  
												      <c:out value="${product.B_pzwh}" />  
												    </c:otherwise>  
												</c:choose>
											</span>
	                                        <span>可拆零： ${product.B_kechai }</span>
	                                    </li>
	                                </ul>
	                            </div>
	                        </li>
	                		<li class="td td-price">
	                        	<div class="td-inner" style="padding-top:40px;">
	                            	<span style="display: block;">单价：<c:choose><c:when test="${islogin && isuserauth }">￥${product.price }</c:when><c:otherwise>审核可见</c:otherwise></c:choose></span>
	                                <span style="display: block;">库存：<c:choose><c:when test="${product.amount>100}">>100</c:when><c:when test="${product.amount<=0}">无</c:when><c:otherwise>${product.amount }</c:otherwise></c:choose></span>
	                            </div>
	                        </li>
	                        <li class="td td-amount">
	                        	<div class="td-inner">
	                                <div class="buy-Num-bd across">
	                                    <input name="buynumInp" type="text" class="buy-numInp" value="1" onkeyup="inputAmount(this)" maxnum="${product.amount }"/>
	                                    <span class="btn-reduce" onclick="lessenamount(${product.id },this)">-</span>
	                                    <span class="btn-add" onclick="addamount(${product.id },this)">+</span>                        
	                                </div>	
	                            </div>
	                        </li>
	                        <li class="td td-op">
	                        	<div class="td-inner">
	                            	<div>
	                            		<c:if test="${product.status==2 && product.amount>0}"><p class="buy-btn"><a href="javascript:addtocart(${product.id });" style="padding-top:0px;padding-bottom:2px;"><i style="top:5px;left:4px"></i>加入购物车</a></p></c:if>
	                                	<c:if test="${product.status==1 }"><p class="buy-btn2"><a>已下架</a></p></c:if>
										<p style="text-align:center;padding-top:6px;"><a href="javascript:del(${product.id });">删除</a></p>
	                                </div>
	                            	                               
	                            </div>
	                        </li>
	                	</ul>
	                </div>
	                
	                </c:forEach>
	                
	                ${pagehtml }
	            </div>
	            </c:if>
	             <c:if test="${list.size()==0 }">
                      <div style="text-align:center;margin-top:40px;"><img src="${ctx }/website/images/smileIco.png"></div>
                      	<div style="text-align:center;margin-top:40px;color:#8b8b8b">这里什么都没有，赶快去收藏吧~</div>
                 </c:if>
            	<!-- end -->
            </div>
        </div>
    </div>
</div>

<%@ include file="/website/common/foot.jsp"%>
</body>
</html>
<script>
var uploader;
$(function(){
	setLeftCur("favorites");
	
	$('.J_select').each(function(){
		if($(this).prev().get(0).checked)
			$(this).parent().addClass('checked');
	})
	
	$('.J_select').click(function(){
		var ischeck=false;
		if($(this).parent().get(0).className.indexOf("checked")==-1)ischeck=true;
		checkbox($(this).parent(),ischeck);
		if($(this).parent().get(0).className.indexOf("allbox")!=-1)selall(ischeck);
		if(!ischeck){
			$(".allbox").each(function(){
				checkbox($(this),ischeck);
			})
		}
	})
})

function gopage(n){
	window.location.href=ctx+"/product/favorites?pno="+n;
}
function topageclick(){
	if($("[name='topagenum']").val()!="")
		gopage($("[name='topagenum']").val());
}
function addamount(pid,obj){
	 var txt=$("[name='buynumInp']",$(obj).parent());
	  var n=parseInt(txt.val());
	  n++;
	  txt.val(n);
	  inputAmount(txt);
}
function lessenamount(pid,obj){
	 var txt=$("[name='buynumInp']",$(obj).parent());
	  var n=parseInt(txt.val());
	  n--;
	  txt.val(n);
	  inputAmount(txt);
}
function addtocart(pid){
	var url=ctx+"/order/addToCart?pid="+pid+"&amount="+$("[name='buynumInp']",$("[pid='"+pid+"']")).val();
//	window.open(url);
	$w.addtocart(url);
}
function dels(){
	var priceids="";
	$(".productbox").each(function(){
		var box=$("[name='cartcheckbox']",$(this)).get(0);
		if(box.checked){
			if(priceids!="")priceids+=',';
			priceids+=box.value;
		}
	})
		if (priceids == "" || priceids == null) {
			alert("请选择要删除的商品")
			return false;
		}
	$w.httpRequest({
		url:ctx+"/product/delfavorites?priceids="+priceids,
		data:{},
		ok:function(ret){
			window.location.reload();
		}
	})
}
function del(pid){
	$w.httpRequest({
		url:ctx+"/product/delfavorites?priceids="+pid,
		data:{},
		ok:function(ret){
			window.location.reload();
		}
	})
}
function selall(ischeck){
	$(".productbox").each(function(){
		checkbox($(this),ischeck);
	})
}
function checkbox(obj,ischeck){
	if(ischeck){
		if(obj.get(0).className.indexOf("checked")==-1){
			obj.addClass("checked");
		}
	}else obj.removeClass("checked");
	$("[name='cartcheckbox']",obj).get(0).checked=ischeck;
	
}
</script>